﻿using System;
using System.Data.Common;
using System.Data.Entity.Infrastructure;

namespace UnitTestUtils.DB.EF
{
    /// <summary>
    /// Use this in conjunction with precreated <see cref="DbConnection"/>s. 
    /// Set Database.DefaultConnectionFactory = new ThrowingFactory(); to ensure that no other db connections are created.
    /// </summary>
    public class ThrowingFactory : IDbConnectionFactory
    {
        /// <summary>
        /// Creates a connection based on the given database name or connection string.
        /// </summary>
        /// <param name="nameOrConnectionString">The database name or connection string.</param>
        /// <returns>
        /// An initialized DbConnection.
        /// </returns>
        public DbConnection CreateConnection(string nameOrConnectionString)
        {
            throw new NotImplementedException();
        }
    }
}